import java.util.*;
public class RemoveStopWords  {
	static String removeStopWords(String input, String stopWords)
	{
		StringBuffer tempStringWithoutStopWords = new StringBuffer();
		HashSet<String> stopHash = new HashSet<String>();
		StringTokenizer stopTokenized = new StringTokenizer(stopWords);
		StringTokenizer inputTokenized = new StringTokenizer(input);
		while(stopTokenized.hasMoreTokens())
		{
			stopHash.add(stopTokenized.nextToken());

		}
		System.out.println(stopHash);
		while(inputTokenized.hasMoreTokens())
		{
			String tempToken = inputTokenized.nextToken();
			String tempTokenLower = tempToken.toLowerCase();
			if(!stopHash.contains(tempTokenLower))
				{
					tempStringWithoutStopWords.append(new StringBuffer(tempToken));
					tempStringWithoutStopWords.append(" ");
				}

		}
		return(new String(tempStringWithoutStopWords));
	}

	public static void main(String[] args) {
		String input = "To be or not to be - that is the question: Whether it is nobler in the mind to suffer, the slings and arrows of outrageous fortune. Or to take up arms against a sea of troubles, and by opposing end them";
		String stop = "a be to the that this or";		
		System.out.println(removeStopWords(input,stop));
	}
	
}